﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace ZH.GPT.Utils
{
    /// <summary>
    /// 文件读取帮助
    /// </summary>
    public static class FileHelper
    {
        public static byte[] ReadFormFileToByteArray(IFormFile formFile)
        {
            byte[] fileBytes;

            using (var stream = formFile.OpenReadStream())
            {
                using (var memoryStream = new MemoryStream())
                {
                    stream.CopyTo(memoryStream);
                    fileBytes = memoryStream.ToArray();
                }
            }
            return fileBytes;
        }
    }
}
